﻿using UnitTest.iRepository;
using UnitTest.Model;

namespace UnitTest.Service;

public class StudentService : IStudentService
{
    private readonly IStudentRepository _studentRepository;

    public StudentService(IStudentRepository studentRepository)
    {
        _studentRepository = studentRepository;
    }

    public async Task<List<Student>> GetList()
    {
        return await _studentRepository.GetList();
    }

    public async Task<Student> GetById(int id)
    {
        return await _studentRepository.GetById(id);
    }

    public async Task<int?> Post(Student student)
    {
        return await _studentRepository.Add(student);
    }

    public async Task<bool> Delete(Student student)
    {
        var res=  await _studentRepository.Delete(student);
        return res > 0 ? true : false;
    }

    public async Task<int> Test(int id)
    {
        return id;
    }
}